home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d2
/
nansi987.arc
/
SETRAW.C
< prev
Wrap
C/C++ Source or Header
|
1987-09-13
|
2KB
|
69 lines
/*_ setraw.c Sat Sep 12 1987 Modified by: Pat Myrto */
/*------ setraw.lc ----------------------------------------------
Microsoft C routines which get and set the current raw/cooked state
of a file, given its DOS file descriptor.
Useful when trying to obtain high console output speeds.
----------------------------------------------------------------*/
#include <dos.h>
#define CARRY 0x1
#define ERROR (-1)
#define TRUE 1
#define FALSE 0
/*---- getraw --------------------------------------------------
Returns TRUE if file fd is a device in raw mode; FALSE otherwise.
Returns ERROR, errorcode is in _doserrno, if DOS error.
----------------------------------------------------------------*/
getraw(fd)
int fd;
{
union REGS inregs;
union REGS outregs;
int flags;
/* if (fd > 2) fd+=2; /* convert to DOS fd */
inregs.x.bx = fd;
inregs.x.ax = 0x4400; /* get file attributes */
flags = intdos(&inregs, &outregs);
if (outregs.x.cflag) return -1;
return (outregs.x.dx & 0x20) ? TRUE : FALSE;
}
/*---- setraw --------------------------------------------------
Sets Raw state of file fd to raw_on (if file is not a device, does nothing).
Returns zero if successful.
Returns ERROR & errorcode in _doserror if DOS error.
----------------------------------------------------------------*/
setraw(fd, raw_on)
int fd, raw_on;
{
union REGS inregs;
union REGS outregs;
inregs.x.ax = 0x4400; /* get file attributes */
inregs.x.bx = fd;
intdos(&inregs, &outregs);
if (outregs.x.cflag) return ERROR;
if ((outregs.x.ax & 0x80) == 0) /* return zero if not device */
return 0;
outregs.x.ax = 0x4401; /* set file attributes */
outregs.x.bx = fd;
outregs.x.dx &= 0xcf; /* clear old raw bit & hi byte */
if (raw_on) outregs.x.dx |= 0x20; /* maybe set new raw bit */
intdos(&outregs, &inregs);
if (outregs.x.cflag) return ERROR;
return 0;
}
/*-- end of setraw.c --*/